<template>
  <div class="container">
    <el-tabs v-model="routerName" class="nav-tab" @tab-click="handleClick">
      <el-tab-pane v-for="item in tabList" :key="item.id" :label="item.label" :name="item.name" />
    </el-tabs>
    <!-- <router-view /> -->
    <div class="setupContent">
      <!-- 公司设置 区分仪信通和天网客户 -->
      <CompanyInformationPage v-if="routerName === 'companyInformation' && accountType === 1" />
      <CompanyInformationTwPage v-if="routerName === 'companyInformation' && accountType === 2" />
      <!-- 员工信息 -->
      <employeeInformationPage v-if="routerName === 'employeeInformation'" />
      <!-- 品牌页设置 -->
      <brandPageSettingsPage v-if="routerName === 'brandPageSettings'" />
    </div>
  </div>
</template>
<script>
import CompanyInformationPage from './companyInformation/index.vue'
import CompanyInformationTwPage from './companyInformation/twIndex.vue'
import employeeInformationPage from './employeeInformation/index.vue'
import brandPageSettingsPage from './brandPageSettings/index.vue'
import { getImShowId } from '@/utils/auth'
export default {
  name: 'CompanySet',
  components: { CompanyInformationPage, employeeInformationPage, CompanyInformationTwPage, brandPageSettingsPage },
  data () {
    return {
      routerName: '',
      accountType: 1, // 仪信通1  天网2
      tabList: [
        { id: 1, label: '公司设置', name: 'companyInformation' },
        { id: 2, label: '员工信息', name: 'employeeInformation' },
        { id: 3, label: '品牌页设置', name: 'brandPageSettings' }
      ]
    }
  },
  created () {
    this.getDistinguishUsers()
    this.routerName = this.$route.meta.name
  },
  methods: {
    handleClick (tab) {
      const routerName = tab._props.name
      this.$router.push({ path: `/setUp/${routerName}` })
    },
    // 区分天网和仪信通用户
    getDistinguishUsers () {
      const reg = /^(sh|SH|Sh|sH)[0-9]{6}$/g
      const account = getImShowId()
      if (reg.test(account)) {
        // 仪信通用户
        this.accountType = 1
      } else {
        this.accountType = 2
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.container {
  margin: 16px;
  background: #fff;
  position: relative;
  .nav-tab {
    width: 100%;
    padding: 16px 16px 0;
    box-sizing: border-box;
  }
  .setupContent {
    height: calc(100vh - 155px);
    overflow-y: scroll;
    &::-webkit-scrollbar {
      width: 0;
      height: 0;
    }
  }
}
</style>
